stage.set_axis(100)
stage.create_grid_overlay(10, "grey")
stage.set_background("soccerfield")
ballx = -80
bally = random.randint(-100,100)
# sprite = codesters.Sprite("image", x, y)
ball = codesters.Sprite("soccerball", ballx, bally)
netx = 90
nety = random.randint(-100,100)
# sprite = codesters.Sprite("image", x, y)
net = codesters.Sprite("soccernet", netx, nety)
net.flip_right_left()
t = codesters.Teacher()
params = t.get_parameters_for_function("Line")
lines = params[0]
try:
tval1 = params[0][0]
except:
tval1 = "DNE"
try:
tval2 = params[0][1]
except:
tval2 = "DNE"
try:
tval3 = params[0][2]
except:
tval3 = "DNE"
try:
tval4 = params[0][3]
except:
tval4 = "DNE"
try:
tval5 = params[0][4]
except:
tval5 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == "ballx", "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add a line command to your code?")
t1.add_failure(tval1 == "bally" and tval6 != 5, "Did you delete the x-start parameter?")
t1.add_failure(tval1 == "bally" and tval2 == "ballx", "Did you reverse ballx and bally?")
t1.add_failure(tval1 == "0", "Did you change the x-start coordinate to ballx?")
t1.add_failure(tval1 != "ballx" and tval1 != "0", "Did you change the x-start coordinate to ballx?")
t2 = TestObjective()
t2.add_success(tval2 == "bally", "Great job!")
t2.add_failure(tval2 == "netx" and tval6 != 5, "Did you delete the y-start coordinate?")
t2.add_failure(tval2 == "0", "Don't forget to change the y-start coordinate to bally?")
t2.add_failure(tval2 != "bally" and tval2 != "0", "Did you change the y-start coordinate to bally?")
t3 = TestObjective()
t3.add_success(tval3 == "netx", "Great job!")
t3.add_failure(tval3 == "nety" and tval6 != 5, "Did you delete the x-end coordinate?")
t3.add_failure(tval3 == "nety" and tval4 == "netx", "Did you reverse bally and ballx?")
t3.add_failure(tval3 == "200", "Don't forget to change the x-end to netx!")
t3.add_failure(tval3 != "netx" and tval3 != "200", "Did you change the x-end coordinate to netx?")
t4 = TestObjective()
t4.add_success(tval4 == "nety", "Great job!")
t4.add_failure(tval4 == '"blue"' and tval6 != 5, "Did you delete the y-end coordinate?")
t4.add_failure(tval4 == "0", "Don't forget to change the y-end coordinate to nety!")
t4.add_failure(tval4 != "nety" and tval4 != "100", "Did you change the y-end coordinate to nety?")
t5 = TestObjective()
t5.add_success(tval5 == '"blue"', "Great job!")
t5.add_failure(tval5 == "DNE" and tval6 != 5, "Did you delete the color parameter?")
t5.add_creative(tval5 != '"blue"' and tval5 != "DNE", "That's a great color too!")
tester = TestManager()
tester.add_test_list([t1, t2, t3, t4, t5])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)